<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title>登录</title>

    <style>
        .wrapper {
            width: 100%;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .box {
            padding: 2rem;
            box-shadow: 1px 1px 3px 2px #c3c3c3;
            border-radius: 2px;
        }
        ul {
            list-style: none;
            width: 18rem;
            margin: 0;
            padding: 0;
        }
        ul li {
            margin-bottom: 10px;
        }
        label {
            width: 4rem;
            display: inline-block;
        }
        #login-btn {
            padding: 0.1rem 2rem;
        }
    </style>
</head>
<body>



    <div class="wrapper">
        <div class="box">
            <form action="/login" method="GET" onsubmit="return login();">
                <ul>
                    <li><h3 style="text-align: center">登录</h3></li>
                    <li><label>用户名</label><input id="username" name="username" type="text" /></li>
                    <li><label>密码</label><input id="password" name="password" type="password" /></li>
                    <li style="text-align: center; margin-top: 1rem">
                        <button type="submit">登录</button>
                    </li>
                </ul>
            </form>
        </div>
    </div>
</body>

<script src="/js/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        <#if err??>
            alert("${(err)!}");
        </#if>
    });

    function login() {
        var username = $("#username").val();
        var pwd = $("#password").val();

        if (!username || $.trim(username) === ""){
            alert("用户名不能为空");
            return false;
        }
        if (!pwd || $.trim(pwd) === "") {
            alert("密码不能为空");
            return false;
        }

        return true;
    }

</script>
</html>